
Public Class DateUtils

    Public Shared Function makeStandardDateString(ByVal strDate As String, ByRef strOut As String) As Boolean
        Dim ok As Boolean = False
        Dim strTmp As String = strDate.Trim()
        Dim strArr As String()
        Dim dd, mm, yyyy As String

        If strTmp.Length > 10 Then
            GoTo lbl_end
        End If

        strArr = strTmp.Split("/")
        If strArr.Length <> 3 Then
            GoTo lbl_end
        End If

        dd = strArr(0)
        mm = strArr(1)
        yyyy = strArr(2)

        If dd.Length < 2 Then
            dd = "0" + dd
        End If

        If mm.Length < 2 Then
            mm = "0" + mm
        End If

        'try to parse
        Try
            Dim test As Date = Date.ParseExact(dd + "/" + mm + "/" + yyyy, "dd/MM/yyyy", System.Globalization.CultureInfo.CurrentUICulture)
        Catch ex As Exception
            ok = False
            GoTo lbl_end
        End Try
        strOut = dd + "/" + mm + "/" + yyyy
        ok = True
lbl_end:
        Return ok
    End Function
End Class
